﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ServiceAdvanced.aspx.cs" Inherits="ServiceAdvanced" %>

<asp:Content ID="Content1" ContentPlaceHolderID="BodyContent" runat="Server">
    <div class="contentfull">
        <div class="breadcrumbs">
            <ul id="crumbs">
                <li><a title="My Account" href="#">My Account</a>
                    <img src="Content/Images/separator.png" alt="&rarr;" class="separator">
                    Buttons 			</li>
            </ul>
        </div>

        <div id="showMessages"></div>


        <div class="top">
            <div class="innerleft">
                <h1>Edit Button &#8220;<%= DisplayServiceName %>&#8221; - Step 5</h1>
            </div>
            <ol id="wizard-menu" class="group">
                <li title="Select button type" style="width: 16.50%; float: left">
                    <a href="ServiceType.aspx?ServiceId=<%= ServiceId.ToString() %>" style="width: 100%" class="wizard-step w-before group red" id="step1">
                        <img src="Images/scan48.png" alt="Type">
                        <span class="mobile_disabled">Type</span>
                    </a>
                </li>
                <li title="Name this button." style="width: 16.50%; float: left">
                    <a href="ServiceName.aspx?ServiceId=<%= ServiceId.ToString() %>" style="width: 100%" class="wizard-step w-before group green" id="step2">
                        <img src="Images/service48.png" alt="Name">
                        <span class="mobile_disabled">Name</span>
                    </a>
                </li>
                <li title="Authorize users for this button." style="width: 16.50%; float: left">
                    <a href="ServiceUsers.aspx?ServiceId=<%= ServiceId.ToString() %>" style="width: 100%" class="wizard-step w-before group orange" id="step3">
                        <img src="Images/user48.png" alt="Users">
                        <span class="mobile_disabled">Users</span>
                    </a>
                </li>
                <li title="Ask questions alongside each scan made by this button." style="width: 16.50%; float: left">
                    <a href="ServiceQuestions.aspx?ServiceId=<%= ServiceId.ToString() %>" style="width: 100%" class="wizard-step w-before group gold" id="step4">
                        <img src="Images/question48.png" alt="Questions">
                        <span class="mobile_disabled">Questions</span>
                    </a>
                </li>
                <li title="Modify advanced settings" style="width: 16.50%; float: left">
                    <a href="ServiceAdvanced.aspx?ServiceId=<%= ServiceId.ToString() %>" style="width: 100%" class="wizard-step w-active group blue" id="step5">
                        <img src="Images/optional48.png" alt="Advanced">
                        <span class="mobile_disabled">Advanced</span>
                    </a>
                </li>
                <li title="Done" style="width: 16.50%; float: left">
                    <a href="ServiceDone.aspx?ServiceId=<%= ServiceId.ToString() %>" style="width: 100%" class="wizard-step w-after group purple" id="review">
                        <img src="Images/confirm48.png" alt="Done">
                        <span class="mobile_disabled">Done</span>
                    </a>
                </li>
            </ol>
        </div>
        <div class="content">

            <form id="advancedPropertiesForm" method="post" action="ServiceDone.aspx">
                <div class="wizard-nav">
                    <input type="submit" name="login" value="Save and Continue" class="black_button blarge next" />
                </div>

                <input type="hidden" name="action" value="editAdvanced" />
                <input type="hidden" name="serviceid" value="<%= ServiceId.ToString() %>">
                <h2 class="large">Advanced Settings</h2>
                <br />
                <fieldset>

                    <h4>Access:</h4>
                    <div class="divradioset">


                        <input type="checkbox" name="deleteSavedScans" <% if(srvProperties.DeleteSavedScans==true){ %> checked="checked" <%}%> class="inputradio" />
                        <label for="deleteSavedScans">Allow users to delete scans saved on device.</label>
                        <br />
                        <input type="checkbox" name="editSavedAnswers" <% if(srvProperties.EditSavedAnswers==true){ %> checked="checked" <%} %> class="inputradio" />
                        <label for="editSavedAnswers">Allow users to edit answers saved on device.</label>
                        <br />
                        <input type="checkbox" name="viewOtherScans" <% if(srvProperties.ViewOtherScans==true){ %> checked="checked" value="1" <%}%> id="viewOtherScans" class="inputradio" />
                        <label for="viewOtherScans">Allow users to view other users' scans.</label>
                        <br />
                        <!--
                        <input type="checkbox" name="strictlyOnline" value="1" id="strictlyOnline" class="inputradio" />
                        <label for="strictlyOnline">Forbid users from backing up scans on-device when connectivity fails.</label><br />

                        <input type="checkbox" id="period_activator" class="inputradio" />

                        <label for="period_activator" class="labelradio">This service should only be active for a limited duration.</label>
                        <br />
                        <div id="advancedOptionsTab" class="indent3">

                            <div style="float: left;">
                                <span style="font-size: 0.75em;">Between:</span>
                                <br />
                                <input name="period_start_date" id="dt_date_start" class="date" type="text" value="">
                                <input name="period_start_time" id="dt_time_start" class="time" type="text" value="">
                            </div>
                            <div style="float: left;">
                                <span style="font-size: 0.75em;">And:</span>
                                <br />
                                <input name="period_end_date" id="dt_date_end" class="date" type="text" value="">
                                <input name="period_end_time" id="dt_time_end" class="time" type="text" value="">
                            </div>
                            <div style="clear: both;">&nbsp;</div>
                        </div>
                        <br />
                        -->
                    </div>
                    <br />
                    <h4>On-device:</h4>

                    <div class="divradioset">
                        <input type="checkbox" name="emailOnUpload" <% if(!string.IsNullOrWhiteSpace(srvProperties.EmailMeOnUploadEmailId)){ %> checked="checked" <%} %> id="emailOnUpload" class="inputradio" />
                        <label for="emailOnUpload" class="labelradio">Email me when on-device scans are uploaded.</label>

                        <div id="emailUploadsTab" class="indent3">
                            <label for="emailToSendUploadsTo">We will send a CSV file to this address:</label>
                            <input type="text" id="emailToSendUploadsTo" name="emailToSendUploadsTo" value="<%= !string.IsNullOrWhiteSpace(srvProperties.EmailMeOnUploadEmailId)?srvProperties.EmailMeOnUploadEmailId:"" %>" class="inputed" />
                        </div>
                    </div>
                    <br />
                    <h4>Miscellaneous:</h4>
                    <!--
                    <div class="divradioset">

                        <input type="checkbox" name="enableGPS" id="enableGPS" value="211135" class="inputradio">
                        <label for="enableGPS" class="labelradio">Track the device's location at the time of each scan. Collect it</label>
                        <br />
                        <div id="questionConditionDiv" style="display: none">
                            <p style="padding-left: 30px; margin-top: 5px;">
                                <input type="hidden" name="gpsQuestionID" value="211135" />

                                <input type="radio" id="gpsQuestionCondition1" name="gpsQuestionCondition" value="pre_submit" /><label for="gpsQuestionCondition1">with questions before submitting any scan.</label>
                                <br />
                                <input type="radio" id="gpsQuestionCondition2" name="gpsQuestionCondition" value="post_submit" /><label for="gpsQuestionCondition2">with questions after submitting any scan.</label><br />
                                <input type="radio" id="gpsQuestionCondition3" name="gpsQuestionCondition" value="valid_scan" /><label for="gpsQuestionCondition3">with questions after submitting a valid scan.</label><br />
                                <input type="radio" id="gpsQuestionCondition4" name="gpsQuestionCondition" value="invalid_scan" /><label for="gpsQuestionCondition4">with questions after submitting a non valid scan.</label><br />
                                <input type="radio" id="gpsQuestionCondition5" name="gpsQuestionCondition" value="noprompt" /><label for="gpsQuestionCondition5">without interruption as a scan property.</label><br />
                            </p>
                        </div>

                    </div>
                    -->

                    <div class="divradioset">
                        <input type="checkbox" name="preferredSymbology" <% if(!string.IsNullOrWhiteSpace(srvProperties.AllowedBarCodes)){ %> checked="checked" <%} %> id="preferredSymbology" class="inputradio">
                        <label for="preferredSymbology" class="labelradio">Improve performance by targeting the barcode format(s) of this service.</label>
                        <div id="preferredSymbologyDiv" style="display: none">
                            <p style="font-size: 13px;" class="indent3">
                                Choose the barcode formats you plan to be scanning <strong>(CTRL + Click)</strong><br />
                                <select id="symbologiesSelect" multiple name="symbologies[]" size="20">
                                    <%= LoadBarCodeFormates() %>
                                </select>
                            </p>
                        </div>
                        <br />
                    </div>
                    <!--
                     <div class="divradioset">
                        <input type="checkbox" name="alterScan" id="alterScan" class="inputradio">
                        <label for="alterScan" class="labelradio">Alter Scan Value </label>
                        <div id="alterScanDiv" class="indent3" style="display: none">
                            <p id="alterScanError" style="display: none; color: #ff0000;">Invalid Input. Both values must be entered.</p>
                            <label for="alterScanPattern">Alter Value Pattern:</label>
                            <span class="lower_comment">Regular expression to parse barcode input.</span>
                            <input type="text" name="alterScanPatternValue" id="alterScanPatternValue" value="" class="inputed">

                            <label for="alterScanReplacement">Alter Value Replacement:</label>
                            <span class="lower_comment">Replacement value as a result of Pattern match.</span>
                            <input type="text" name="alterScanReplacementValue" id="alterScanReplacementValue" value="" class="inputed">
                        </div>
                        <br />
                        <input type="checkbox" name="alterResponse" id="alterResponse" class="inputradio">
                        <label for="alterResponse" class="labelradio">Alter Response Value</label>
                        <div id="alterResponseDiv" class="indent3" style="display: none">
                            <p id="alterResponseError" style="display: none; color: #ff0000;">Invalid Input. Both values must be entered.</p>
                            <label for="alterResponsePattern">Alter Response Pattern:</label>
                            <span class="lower_comment">Regular expression to parse barcode's response.</span>
                            <input type="text" name="alterResponsePatternValue" id="alterResponsePatternValue" value="" class="inputed">

                            <label for="alterResponseReplacement">Alter Response Replacement:</label>
                            <span class="lower_comment">Replacement response as a result of Pattern match.</span>
                            <textarea style="height: 10em;" name="alterResponseReplacementValue" id="alterResponseReplacementValue" class="inputed"></textarea>

                        </div>
                    </div>
                    -->
                    <br />
                    <input type="submit" name="login" value="Save and Continue" class="black_button blarge right" />
                </fieldset>
            </form>
            <script type="text/javascript" src="Scripts/jquery.calendrical.js"></script>
            <script>
                $(document).ready(function () {
                    $("#emailUploadsTab, #postbackUploadsTab, #advancedOptionsTab, #directLookupTab, #directHistoryTab").hide();

                    $("#enableGPS").change(function () {
                        $(this).next().next().next().slideToggle();
                    });
                    $("#preferredSymbology").change(function () {
                        $(this).next().next().slideToggle();
                        if ($(this).attr('checked')) {
                            $('#symbologiesSelect > option').attr('selected', 'selected');
                        } else if (!$(this).attr('checked')) {
                            $('#symbologiesSelect > option').removeAttr('selected');
                        }
                    });

                    $('#dt_date_start, #dt_time_start, #dt_date_end, #dt_time_end').calendricalDateTimeRange({ usa: 1, showFutureOnly: 1, defaultHour: 18 });

                    $("#emailOnUpload").click(function (event) {
                        if ($('#emailUploadsTab').is(':visible')) {
                            $('#emailToSendUploadsTo').val('');
                            $("#emailUploadsTab").slideUp();
                        } else {
                            $("#emailUploadsTab").slideDown();
                        }
                    });
                    if ($("#emailOnUpload").attr('checked')) {
                        $("#emailUploadsTab").slideDown();
                    }

                    $("#postbackOnUpload").click(function (event) {
                        if ($('#postbackUploadsTab').is(':visible')) {
                            $('#postbackUploadURL').val('');
                            $("#postbackUploadsTab").slideUp();
                        } else {
                            $("#postbackUploadsTab").slideDown();
                        }
                    });
                    if ($("#postbackOnUpload").attr('checked')) {
                        $("#postbackUploadsTab").slideDown();
                    }

                    $("#enableDirectLookup").click(function (event) {
                        if ($('#directLookupTab').is(':visible')) {
                            $('#directLookupURL').val('');
                            $("#directLookupTab").slideUp();
                        } else {
                            $("#directLookupTab").slideDown();
                        }
                    });
                    if ($("#enableDirectLookup").attr('checked')) {
                        $("#directLookupTab").slideDown();
                    }

                    $("#enableDirectHistory").click(function (event) {
                        if ($('#directHistoryTab').is(':visible')) {
                            $('#directHistoryURL').val('');
                            $("#directHistoryTab").slideUp();
                        } else {
                            $("#directHistoryTab").slideDown();
                        }
                    });
                    if ($("#enableDirectHistory").attr('checked')) {
                        $("#directHistoryTab").slideDown();
                    }

                    $("#period_activator").click(function (event) {
                        if ($('#advancedOptionsTab').is(':visible')) {
                            $('#dt_date_start, #dt_time_start, #dt_date_end, #dt_time_end').val('');
                            $("#advancedOptionsTab").slideUp();
                        } else {
                            $("#advancedOptionsTab").slideDown();
                        }
                    });

                    if ($("#period_activator").attr('checked')) {
                        $("#advancedOptionsTab").slideDown();
                    }
                    if ($("#preferredSymbology").attr('checked')) {
                        $("#preferredSymbologyDiv").slideDown();
                    }

                    $("#alterScan").click(function (event) {
                        if ($('#alterScanDiv').is(':visible')) {
                            $('#alterScanPatternValue').val('');
                            $('#alterScanReplacementValue').val('');
                            $('#alterScanDiv').slideUp();
                            $("#alterScanError").slideUp();
                        } else {
                            $('#alterScanDiv').slideDown();
                        }
                    });
                    $("#alterResponse").click(function (event) {
                        if ($('#alterResponseDiv').is(':visible')) {
                            $('#alterResponsePatternValue').val('');
                            $('#alterResponseReplacementValue').val('');
                            $('#alterResponseDiv').slideUp();
                            $("#alterResponseError").slideUp();
                        } else {
                            $('#alterResponseDiv').slideDown();
                        }
                    });

                    $('#advancedPropertiesForm').submit(function () {
                        var valid_input = true;
                        if ($("#alterScan").is(":checked")) {
                            var spv = $("#alterScanPatternValue").val();
                            var srv = $("#alterScanReplacementValue").val();
                            if (jQuery.trim(spv).length == 0 || jQuery.trim(srv).length == 0) {
                                $("#alterScanError").slideDown();
                                $("#alterScanDiv").effect("highlight", {}, 1500);
                                valid_input = false;
                            } else {
                                $("#alterScanError").slideUp();
                                valid_input = true;
                            }
                        }
                        if ($("#alterResponse").is(":checked")) {
                            var rpv = $("#alterResponsePatternValue").val();
                            var rrv = $("#alterResponseReplacementValue").val();
                            if (jQuery.trim(rpv).length == 0 || jQuery.trim(rrv).length == 0) {
                                $("#alterResponseError").slideDown();
                                $("#alterResponseDiv").effect("highlight", {}, 1500);
                                valid_input = false;
                            } else {
                                $("#alterResponseError").slideUp();
                                valid_input = true;
                            }
                        }
                        return valid_input;
                    });

                });
            </script>

        </div>
    </div>
    <!-- /.contentfull -->
</asp:Content>

